package com.zang.array;

/**
 * @Author: ZVerify
 * @Description: TODO
 * @DateTime: 2022/10/2 13:32
 **/
public class 有序数组的平方 {

    public int[] sortedSquares(int[] nums) {

        int[] ints = new int[nums.length];
        int index = 0;
        int i = 0;
        int j = nums.length-1;
        while (i<=j){
            if (nums[i]*nums[i]>nums[j]*nums[j]){
                ints[index]=nums[i]*nums[i];
            }else {
                ints[index]=nums[j]*nums[j];
            }
            index++;
        }
        return ints;
    }
}
